<%@page import="cfs.databean.FundPriceHistory"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.HashMap"%>
<%@page import="cfs.databean.Fund"%>
<jsp:include page="tempHeader.jsp" />
<jsp:include page="tempMenubar.jsp" />
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page import="cfs.databean.Customer"%>

<hr><div id="container">
        <div id="content" class="wrap">    
               <hr><h2 class="separate">Fund List Available</h2>
               <div class="marginBottom30 clearFix">
                   <table class="card-activity expandable" cellspacing="5">
        		<thead style="text-align: center;">
			<tr>
				<th class="header" width ="50" style="text-align:left;"><span class="under"><a href="#"
						title="Sort by Type" tabindex="65">Number</a></span><span
					class="sorter card-noprint">&nbsp;&nbsp;&nbsp;</span></th>
				<th class="header" width ="100" style="text-align:left;"><span class="under"><a href="#"
						title="Sort by Post Date" tabindex="64">Fund Symbol</a></span><span
					class="sorter card-noprint" style="text-align:left;">&nbsp;&nbsp;&nbsp;</span></th>
				<th class="header" width ="240" style="text-align:left;"><span class="under"><a href="#"
						title="Sort by Description" tabindex="66">Fund Name</a></span><span
					class="sorter card-noprint">&nbsp;&nbsp;&nbsp;</span></th>
				<th class="amount header" width ="140" style="text-align:right;"><span class="under"><a
						href="#" title="Sort by Amount" tabindex="67">Latest Price</a></span><span
					class="sorter card-noprint"></span></th>
				<th class="amount header" width ="140" style="text-align:right;"><span class="under"><a
						href="#" title="Sort by Amount" tabindex="67">Latest Date</a></span></th>
				<th class="amount header" width ="140" style="text-align:right;"><span class="under"><a
						href="#" title="Sort by Amount" tabindex="67">Price Diff</a></span><span
					class="sorter card-noprint"></span></th>
                        </tr>
		</thead>

		<tbody>
                <%
                    Fund[] fundList = (Fund[]) request.getAttribute("fundList");
                    HashMap fundDiffList = (HashMap) request
				.getAttribute("resultDifference");
                    ArrayList<FundPriceHistory> fundPriceList = (ArrayList<FundPriceHistory>) request
				.getAttribute("fundPriceList");
                    if (fundList != null)
			for (int i = 0; i < fundList.length; i++) {
				Fund item = fundList[i];
                %>
                            <tr class="summary">
                                <td><%=i + 1%>.</td>
                                <td><a href="viewFund.do?selectedFund=<%=item.getFund_id()%>"><%=item.getSymbol()%></a></td>
                                <td><%=item.getName()%></td>
                                
                                <%
                                        String latestPrice = "0.0";
					String latestDate = null;
					String priceDiff = "";
					try {
						priceDiff = (String) fundDiffList
								.get(item.getFund_id());
					} catch (Exception e) {
						priceDiff = "Not initiated";
					}
					//for(int x=0;x<fundList.length;x++){
					if (fundPriceList != null && fundPriceList.size() > 0) {
						for (int z = 0; z < fundPriceList.size(); z++) {
							if (fundPriceList.get(z).getFund_id() == item
									.getFund_id()) {
								latestPrice = fundPriceList
										.get(z)
										.formatDecimal(
												fundPriceList.get(z).getPrice());
								latestDate = fundPriceList.get(z).formatDate(
										fundPriceList.get(z).getPrice_date());
		%>

                                    <td style="text-align: right;">&#36;<%=latestPrice%></td>
                                    <td style="text-align: right;"><%=latestDate%></td>
                                    <td style="text-align: right;">&#36;<%=priceDiff%></td>
	</tr>
	<%
		break;
						}
					}
				}
			}
	%>
			
		</tbody>
	</table>
       
               <hr><h2 class="separate"></h2>
                <div class="col1-3">
                    <i>*to purchase funds click on fund hyperlink</i>
                </div>
                </div>
        </div>
</div>
<jsp:include page="tempBottom.jsp" />